clear
clc
%=================PRIPRAVA DAT
%cd C:\Users\xfejfar\Desktop
%mData = load('clarinet_talking_3d_zcr_octave.csv'); %nefunguje
mData = load('clarinet_talking_3d_freq_octave.csv');
%mData = load('heavy_silence_3d_std_octave_bin.csv');

TrainData=mData(1:2:end,1:3)';
TrainTargets=mData(1:2:end,4)';
TestData=mData(2:2:end,1:3)';
TestTargets=mData(2:2:end,4)';

topology = [14 7 1];
MLPNet = newff(TrainData, TrainTargets, topology);%...
    %, {'purelin', 'purelin', 'purelin'}, 'trainlm', 'learngdm', 'mse');
%, {'logsig', 'purelin', 'tansig'}, 'trainlm', 'learngdm', 'mse');
%MLPNet.trainFcn='trainb';
%MLPNet.trainParam.epochs=300;
MLPNet.trainParam.showWindow = false;
net = train(MLPNet, TrainData, TrainTargets);

simOut = sim(net, TestData);
simOutDiscrete = round(simOut);
%plotregression(TestTargets,simOutDiscrete);

for i=1:length(TestTargets(1,:))
  if (TestTargets(i)==simOutDiscrete(i))
    shoda(i)=1;
  else
    shoda(i)=0;
  end	
end

uspesnost=sum(shoda)/length(shoda)*100